package display;

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.springframework.web.context.*;

import domain.*;

public class EliminarSubCategoria extends PageController {
  
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		SubCategoriaRepository subCategorias = (SubCategoriaRepository) context.getBean("SubCategoriaRepository");
		try {
			String id = request.getParameter("id");
			int idSubCategoria = Integer.parseInt(id);
			SubCategoria subCategoria = new SubCategoria();
			subCategoria.setId(idSubCategoria);
			subCategorias.deleteSubCategoria(subCategoria);
			response.sendRedirect("listaSubCategorias");
		} catch (Exception e) {
			request.setAttribute("mensaje",e.getMessage());
			forward("/paginaError.jsp",request,response);
		}
	}
}